package app;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		URL startPage = null;
		try {
			startPage = new URL(args[0]);
			if(args.length == 2 && args[1].equals("scan")) {
				Spider s = new Spider(startPage);
				s.generateGraph();
				s.saveGraph();

				System.out.println(s.toString());
			}
			else {
				System.out.println("args: baseURL scan");
			}
		} catch (MalformedURLException e) {
			System.out.println(startPage + " is not a valid URL");
		} catch (IOException e) {
			System.out.println("Couldn't access graph.ser; run again the program");
		} catch(ArrayIndexOutOfBoundsException e) {
			System.out.println("args: baseURL scan");
		}		
	}
}
